/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package player;

import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.math.Vector3f;

/**
 *
 * @author adamgovan
 */
public class PlayerMovement {

    public CharacterControl player;
    public Vector3f walkDirection = new Vector3f();
    public boolean left = false, right = false, up = false, down = false;
    public CapsuleCollisionShape capsuleShape;
    public float playerSpeed = 0.3f;

    //constructor : defaults with ground movement
    public PlayerMovement() {
        capsuleShape = new CapsuleCollisionShape(1.5f, 5f, 1);
        player = new CharacterControl(capsuleShape, 0.05f);
        player.setJumpSpeed(20);
        player.setFallSpeed(30 - (int) playerSpeed);
        player.setGravity(70);
        player.setPhysicsLocation(new Vector3f(-140, 10, -10));
    }
    // I noticed my camera can invert itself. best to put in some limitation

    public void MouseFunctions() {
    }

    //same as default
    public void setGroundMovement() {
        player = new CharacterControl(capsuleShape, 0.05f);
        player.setJumpSpeed(20);
        player.setFallSpeed(50);
        player.setGravity(60);
        player.setPhysicsLocation(new Vector3f(-140, 10, -10));
    }

    //implementing floating to the top. 
    public void setWaterMovement() {
        player = new CharacterControl(capsuleShape, 0.05f);
        player.setJumpSpeed(10);
        player.setFallSpeed(10);
        player.setGravity(0);
        player.setPhysicsLocation(new Vector3f(0, 10, 0));
    }

    //going to make counting thread for as long as it's up.
    public void toggleSprint() {
        if (playerSpeed == 0.9f) {
            playerSpeed = 0.3f;
        } else {
            playerSpeed = 0.9f;
        }

    }

    public CharacterControl Control() {
        return player;
    }

    public void spawnTown() {
        player.setPhysicsLocation(new Vector3f(0, 10, 0));
    }

    public void spawnCountry() {
        player.setPhysicsLocation(new Vector3f(-283, 15, -121));
    }

    public void getLocation() {
        System.out.println(player.getPhysicsLocation());
    }
}
